#  -*- coding: utf-8 -*-

from .fix_stop_loss import FixStopLoss
from .tracking_stop_loss import TrackingStopLoss
from .fix_ma20_3_stop_loss import FixMA20StopLoss
from .keep_dates_stop_loss import KeepDatesStopLoss


class StopLossFactory:
    @staticmethod
    def get_stop_loss_policy(account, strategy_option,name):
        if 'fixed' == name:
            max_loss = float(strategy_option.properties['max_loss'])
            return FixStopLoss(account, max_loss)
        elif 'tracking' == name:
            max_loss = float(strategy_option.properties['max_loss'])
            return TrackingStopLoss(account, max_loss)
        elif 'fixed_ma20_3' == name:
            max_loss = 3
            return FixMA20StopLoss(account, max_loss)
        elif 'keep_dates' == name:
            max_keep_dates = int(strategy_option.properties['max_keep_dates'])
            return KeepDatesStopLoss(account, max_keep_dates)